﻿using Volo.Abp.Modularity;
using Volo.Abp.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace MyBookStore.EntityFrameworkCore
{
    [DependsOn(typeof(AbpEntityFrameworkCoreModule))]
    public class MyBookStoreEntityFrameworkCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<MyBookStoreDbContext>(options =>
            {
                //启用默认通用存储库，DDD应始终通过聚合根访问子实体
                //options.AddDefaultRepositories();
                //开启后，非聚合根实体也支持IRepository注入
                options.AddDefaultRepositories(true);
            });
            Configure<AbpDbContextOptions>(opt =>
            {
                opt.UseSqlServer();
            });
        }
    }
}
